package com.gk.ScheduleTask;

import com.gk.dao.ZxyUntreatedGuoYaoJLDataDao;
import com.gk.service.OtherBillService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.scheduling.annotation.Async;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

/**
 * 千方定时器
 */
@Component
@Slf4j
public class QFScheduleTask {
    @Resource
    private ZxyUntreatedGuoYaoJLDataDao getGuoYaoJLDataDao;

    //每天早上5点执行
    @Async
    @Scheduled(cron = "0 0 7 * * ?")  //
    public void getGuoYaoBackWriteUntreatedJLData() {
        //TODO 采购退货质量报表
        List<Integer> zxyZlbuybackandbaosunreviewjlUntreateds = getGuoYaoJLDataDao.getZxyZlbuybackandbaosunreviewjlUntreated();
        for (Integer id : zxyZlbuybackandbaosunreviewjlUntreateds) {
            getGuoYaoJLDataDao.ZxyZlbuybackandbaosunreviewjlUntreated_pro(id);
        }
        //TODO 采购收货记录质量报表
        List<Integer> zxyZlbuyshjlUntreateds = getGuoYaoJLDataDao.getZxyZlbuyshjlUntreated();
        for (Integer id : zxyZlbuyshjlUntreateds) {
            getGuoYaoJLDataDao.ZxyZlbuyshjlUntreated_pro(id);
        }
        //TODO 采购验收记录质量报表
        List<Integer> zxyZlbuyzlysjlUntreateds = getGuoYaoJLDataDao.getZxyZlbuyzlysjlUntreated();
        for (Integer id : zxyZlbuyzlysjlUntreateds) {
            getGuoYaoJLDataDao.ZxyZlbuyzlysjlUntreated_pro(id);
        }
        //TODO 库存
        List<Integer> zxyZlgoodsstocksUntreateds = getGuoYaoJLDataDao.getZxyZlgoodsstocksUntreated();
        for (Integer id : zxyZlgoodsstocksUntreateds) {
            getGuoYaoJLDataDao.ZxyZlgoodsstocksUntreated_pro(id);
        }
        //TODO 不合格药品记录质量报表
        List<Integer> zxyZlnoqualifiedjlUntreateds = getGuoYaoJLDataDao.getZxyZlnoqualifiedjlUntreated();
        for (Integer id : zxyZlnoqualifiedjlUntreateds) {
            getGuoYaoJLDataDao.ZxyZlnoqualifiedjlUntreated_pro(id);
        }
        //TODO 销售退回记录质量报表
        List<Integer> zxyZlsalebackjlUntreateds = getGuoYaoJLDataDao.getZxyZlsalebackjlUntreated();
        for (Integer id : zxyZlsalebackjlUntreateds) {
            getGuoYaoJLDataDao.ZxyZlsalebackjlUntreated_pro(id);
        }
        //TODO 销售出库复核记录质量报表
        List<Integer> zxyZlsalereviewjlUntreateds = getGuoYaoJLDataDao.getZxyZlsalereviewjlUntreated();
        for (Integer id : zxyZlsalereviewjlUntreateds) {
            getGuoYaoJLDataDao.ZxyZlsalereviewjlUntreated_pro(id);
        }
        //TODO 委托运输记录记录质量报表
        List<Integer> zxyZlwtysjlUntreateds = getGuoYaoJLDataDao.getZxyZlwtysjlUntreated();
        for (Integer id : zxyZlwtysjlUntreateds) {
            getGuoYaoJLDataDao.ZxyZlwtysjlUntreated_pro(id);
        }
        //TODO 养护记录
//        List<Integer> zxyZlyhjlUntreateds = getGuoYaoJLDataDao.getZxyZlyhjlUntreated();
//        for (Integer id : zxyZlyhjlUntreateds) {
//            getGuoYaoJLDataDao.ZxyZlyhjlUntreated_pro(id);
//        }
    }

    @Resource
    private OtherBillService otherBillService;

    @Async
    @Scheduled(cron = "0 30 7 L * ?")  //每月最后一日的上午10:30触发
    public void CreateQFYHMaintainRecord() {
        otherBillService.CreateQFYHMaintainRecord();
    }

}
